package com.caimore.entity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.concurrent.locks.ReentrantLock;

public class SMSMessageMgr {
    private static SMSMessageMgr oInstance = new SMSMessageMgr();
    private volatile boolean OkBool = false;
    private volatile boolean CrBool = false;
    private volatile String CSCAstr = null;
    private volatile String CMGLstr = null;
    private volatile int ErrorBool = 0;
    private volatile boolean READYbool = false;
    private volatile String SmsType = null;
    private volatile String HCMGSstr = null;
    private LinkedList<ArrayList<SMSRecvMsg>> LstRecvCMGLContext = new LinkedList<>();
    private ReentrantLock LockRecvCMGLContext = new ReentrantLock();
    private LinkedList<ArrayList<String>> Lst8332CMGL = new LinkedList<>();
    private ReentrantLock Lock8332CMGL = new ReentrantLock();
    private LinkedList<SendSmsParam> LstSendSmsParam = new LinkedList<>();
    private ReentrantLock LockSendSmsParam = new ReentrantLock();
    public Map<Integer, String> longSMSMessage = new HashMap<Integer, String>();

    public static SMSMessageMgr getInstance() {
        return oInstance;
    }

    private SMSMessageMgr() {
    }

    public void addRecCMGLMessage(ArrayList<SMSRecvMsg> mes) {
        try {
            this.LockRecvCMGLContext.lock();
            this.LstRecvCMGLContext.add(mes);
        } finally {
            this.LockRecvCMGLContext.unlock();
        }
    }

    public ArrayList<SMSRecvMsg> delRecvCMGLMessage() {
        ArrayList<SMSRecvMsg> mes = new ArrayList<SMSRecvMsg>();
        try {
            this.LockRecvCMGLContext.lock();
            while (!this.LstRecvCMGLContext.isEmpty()) {
                ArrayList<SMSRecvMsg> mes2 = this.LstRecvCMGLContext.removeFirst();
                if (mes2 == null || mes2.size() <= 0) continue;
                for (SMSRecvMsg oSMSRecvMsg : mes2) {
                    mes.add(oSMSRecvMsg);
                }
            }
        } finally {
            this.LockRecvCMGLContext.unlock();
        }
        return mes;
    }

    public void addCMGL8332(ArrayList<String> mes) {
        try {
            this.Lock8332CMGL.lock();
            this.Lst8332CMGL.add(mes);
        } finally {
            this.Lock8332CMGL.unlock();
        }
    }

    public ArrayList<String> delCMGL8332() {
        ArrayList<String> mes = null;
        try {
            this.Lock8332CMGL.lock();
            if (!this.Lst8332CMGL.isEmpty()) {
                mes = this.Lst8332CMGL.removeFirst();
            }
        } finally {
            this.Lock8332CMGL.unlock();
        }
        return mes;
    }

    public void addSendSmsParam(SendSmsParam mes) {
        try {
            this.LockSendSmsParam.lock();
            this.LstSendSmsParam.add(mes);
        } finally {
            this.LockSendSmsParam.unlock();
        }
    }

    public SendSmsParam delSendSmsParam() {
        SendSmsParam mes = null;
        try {
            this.LockSendSmsParam.lock();
            if (!this.LstSendSmsParam.isEmpty()) {
                mes = this.LstSendSmsParam.removeFirst();
            }
        } finally {
            this.LockSendSmsParam.unlock();
        }
        return mes;
    }

    public void setOK(boolean bOK) {
        this.OkBool = bOK;
    }

    public boolean getOK() {
        return this.OkBool;
    }

    public void setERROR(int bERROR) {
        this.ErrorBool = bERROR;
    }

    public int getERROR() {
        return this.ErrorBool;
    }

    public void setREADY(boolean bREADY) {
        this.READYbool = bREADY;
    }

    public boolean getREADY() {
        return this.READYbool;
    }

    public void setCR(boolean bCR) {
        this.CrBool = bCR;
    }

    public boolean getCR() {
        return this.CrBool;
    }

    public void setCSCA(String sCSCA) {
        this.CSCAstr = sCSCA;
    }

    public String getCSCA() {
        return this.CSCAstr;
    }

    public void setCMGL(String sCMGL) {
        this.CMGLstr = sCMGL;
    }

    public String getCMGL() {
        return this.CMGLstr;
    }

    public void setSmsType(String sSmsType) {
        this.SmsType = sSmsType;
    }

    public String getSmsType() {
        return this.SmsType;
    }

    public void setHCMGS(String sHCMGS) {
        this.HCMGSstr = sHCMGS;
    }

    public String getHCMGS() {
        return this.HCMGSstr;
    }
}

